<template>
	<view class="page-body">
		<!-- 页面内容开始 -->

		<el-tabs v-model="activeName" type="card">
			<el-tab-pane label="首页轮播图" name="index-swiper">
				<index-swiper :localdata="indexSwiper" :page-list="pageList" v-if="complete"></index-swiper>
			</el-tab-pane>
			<el-tab-pane label="首页宫格按钮" name="index-grid-btn">
				<index-grid-btn :localdata="indexGridBtn" :page-list="pageList" v-if="complete"></index-grid-btn>
			</el-tab-pane>
		</el-tabs>

		<!-- 页面内容结束 -->
	</view>
</template>

<script>
	var that;													// 当前页面对象
	var vk = uni.vk;									// vk实例
	import indexSwiper from "./components/index-swiper"
	import indexGridBtn from "./components/index-grid-btn"
	export default {
		components:{
			indexSwiper,
			indexGridBtn
		},
		data() {
			// 页面数据变量
			return {
				// init请求返回的数据
				data:{

				},
				// 表单请求数据
				form1:{

				},
				activeName:"index-swiper",
				complete:false,
				pageList:[]
			}
		},
		// 监听 - 页面每次【加载时】执行(如：前进)
		onLoad(options = {}) {
			that = this;
			vk = that.vk;
			that.options = options;
			that.init(options);
		},
		// 监听 - 页面【首次渲染完成时】执行。注意如果渲染速度快，会在页面进入动画完成前触发
		onReady(){

		},
		// 监听 - 页面每次【显示时】执行(如：前进和返回) (页面每次出现在屏幕上都触发，包括从下级页面点返回露出当前页面)
		onShow() {


		},
		// 监听 - 页面每次【隐藏时】执行(如：返回)
		onHide() {


		},
		// 函数
		methods: {
			// 页面数据初始化函数
			init(options){
				vk.callFunction({
					url: 'admin/business/sys/dynamicPages.getList',
					title: '请求中...',
					data: {
						
					},
					success: (data) => {
						that.data = data;
						that.complete = true;
					}
				});
				vk.callFunction({
					url: 'admin/business/sys/page.getList',
					data: {
						pagination:{
							pageIndex: 1,
							pageSize: 500
						}
					},
					success: (data) => {
						that.pageList = data.rows;
					}
				});
			},
			// 页面跳转
			pageTo(path){
				vk.navigateTo(path);
			},

		},
		// 计算属性
		computed:{
			indexSwiper(){
				let that = this;
				return vk.pubfn.getListItem(that.data.rows, "data_id", "index-001");
			},
			indexGridBtn(){
				let that = this;
				return vk.pubfn.getListItem(that.data.rows, "data_id", "index-002");
			}
		}
	}
</script>
<style lang="scss" scoped>
	.page-body{

	}
</style>
